package com.dmall.modules.admin.service.impl;

import com.dmall.modules.admin.entity.AdminUser;
import com.dmall.modules.admin.entity.AdminUserToken;
import com.dmall.modules.admin.mapper.AdminUserMapper;
import com.dmall.modules.admin.mapper.AdminUserTokenMapper;
import com.dmall.modules.admin.service.ShiroService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author Chen 2017/12/7
 */
@Service
public class ShrioServiceImpl implements ShiroService{
    @Autowired
    AdminUserMapper adminUserMapper;
    @Autowired
    AdminUserTokenMapper adminUserTokenMapper;

    /**
     * 根据token查询用户
     * @param accessToken
     * @return
     */
    @Override
    public AdminUserToken queryByToken(String accessToken) {
        AdminUserToken token = new AdminUserToken();
        token.setToken(accessToken);
        return adminUserTokenMapper.selectOne(token);
    }

    /**
     * 查询用户
     * @param userId
     * @return
     */
    @Override
    public AdminUser queryUser(Long userId) {
        return adminUserMapper.selectByPrimaryKey(userId);
    }
}
